<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微信长按识别二维码</title>
    <style>
        body {
            background: #f5f5f5;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 20px;
        }
        #qrcode-container {
            margin: 30px auto;
            padding: 15px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .tip {
            color: #666;
            font-size: 14px;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <h2>扫描二维码查看内容</h2>
    <div id="qrcode-container"></div>
    <p class="tip">长按二维码图片识别内容</p>

    <!-- 依赖库 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>

    <script>
    $(function(){
        // 生成二维码配置
        const config = {
            text: "https://example.com",  // 替换为目标链接
            width: 256,                  // 二维码宽度
            height: 256,                 // 二维码高度
            colorDark: "#000000",        // 深色模块颜色
            colorLight: "#ffffff"        // 浅色模块颜色
        };

        // 生成二维码画布
        $('#qrcode-container').qrcode(config);
        
        // 将canvas转换为img（关键步骤）
        setTimeout(() => {
            const canvas = document.querySelector('canvas');
            const img = new Image();
            img.src = canvas.toDataURL('image/png');
            img.alt = "可识别二维码";
            img.style.width = '100%';
            $('#qrcode-container').empty().append(img);
        }, 100);
    });
    </script>
</body>
</html>